<template>
    <div class="item-percentage-box">
        <div class="item-percentage" v-for="(item,index) in percentage.list">
            <div class="top-title justify-align">
                <div class="lf-fa-name-box left-justifying">
                    <div class="num">{{index + 1 }}</div>
                    <div class="name">{{item.C1}}</div>
                </div>
                <div class="val-num">
                    {{item.C2}}
                </div>
            </div>
            <el-progress :percentage="item.C3" :show-text="false" color="#4D9AFF" />
        </div>
    </div>
</template>

<script setup>
import { onMounted, reactive,onUnmounted } from "vue";
import { getMechanicTopList } from "@/api/api";

const percentage = reactive({
  list: [
    // {name:'这里是工厂名称',val:132,percentage:90},
    // {name:'这里是工厂名称',val:120,percentage:85},
    // {name:'这里是工厂名称',val:110,percentage:80},
    // {name:'这里是工厂名称',val:42,percentage:42},
    // {name:'这里是工厂名称',val:30,percentage:30},
  
],})
const getgMechanicTopListData = (()=>{
  getMechanicTopList().then((res) => {
   
    percentage.list = res.data.data
    // console.log('percentageItem')
  })
})
let timeIntervalItem = null
onMounted(() => {
 
  getgMechanicTopListData()
  timeIntervalItem = setInterval(() => {
        // Todo...
        
        getgMechanicTopListData()
        
      }, 30000)// 每60秒发送一次请求
});
//在页面销毁之前先销毁定时器
onUnmounted(() => {
  clearTimeout(timeIntervalItem)
  timeIntervalItem = null
})
</script>

<style lang="scss" scoped>
.justify-align {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.left-justifying {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}
.item-percentage-box{
    height: 239px;overflow-y: auto;

}
  /* 设置滚动条宽度为10px */
.item-percentage-box::-webkit-scrollbar {
  width: 5px;
}
/* 设置滚动条的颜色和样式 */
.item-percentage-box::-webkit-scrollbar-thumb {
  background-color: #384a64;
  border-radius: 5px;
}

.item-percentage-box::-webkit-scrollbar-thumb:hover {
  background-color: #29384e;
}
   
.item-percentage{
    padding: 6px 0;
    
    .top-title{
        padding-bottom: 5px;color: #C1CEDE;
    }
    .val-num{
        color: #fff;
    }
    .num{
        width: 20px;
height: 20px;

border-radius: 4px;
background: linear-gradient(180deg, rgba(77, 154, 255, 0.2) 0%, rgba(168, 207, 255, 0.1) 100%);


border: 1px solid rgba(230, 241, 255, 0.1);

box-shadow: 0px 2px 4px  #001A4C;margin-right: 10px;text-align: center;
    }
}
</style>